﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
	Inherits="System.Web.Mvc.ViewPage<IntellectShop.Web2.Hardware.ViewModels.SoftwareIndexViewModel>" %>
<%@ Import Namespace="IntellectShop.Web2.Hardware.Code" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%= Html.Resource("Index") %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<script type="text/javascript" src='<%= ResolveUrl("~/Scripts/live.filter.1.2/jquery.liveFilter.min.js")%>'></script>
	<script type="text/javascript">
		$(document).ready(function () {
			$('table.live_filter').liveFilter('fade');
		});
	</script>

	<h1><%= Html.Resource("SoftwaresIndex") %></h1>
	<p>
		<%= Html.ActionLink(Html.Resource("CreateNewSoftware"), "Create") %>
	</p>
<% if (Model.Softwares.Any())
	{ %>
	<p>
		<%= Html.ActionLink(Html.Resource("ExportXML"), "ExportXml") %>
	</p>
	<p>
		<%= Html.Resource("Strings, LiveSearch") %>:
		<input class="filter" name="livefilter" type="text" value="" />
	</p>
	<table class="live_filter hovered">
		<thead>
		<tr>
			<th>
				<%= Html.LabelFor(model => model.Softwares.First().Value.FirstOrDefault().Code) %>
			</th>
			<th>
				<%= Html.LabelFor(model => model.Softwares.First().Value.FirstOrDefault().Name) %>
			</th>
			<th>
				<%= Html.LabelFor(model => model.Softwares.First().Value.FirstOrDefault().Price) %>
			</th>
			<th>
				<%= Html.Resource("Action") %>
			</th>
		</tr>
		</thead>
		<tbody>
		<% foreach (var category in Model.Softwares.Keys)
		{ %>
			<tr>
				<td class="subheader" colspan="4">
					<%= Html.ActionLink(
						category.Name,
						"Browse",
						new { CategoryID = category.CategoryID }, new { style = "font-weight: bold;background-color: transparent;" })%>
				</td>
			</tr>
			<% foreach (var item in Model.Softwares[category])
			{ %>
			<tr>
				<td style="text-align: right; white-space:nowrap;">
					<%= Html.Encode(item.Code) %>
				</td>
				<td>
					<a name="id<%= item.CommodityID %>"></a>
					<%= item.Name %>
				</td>
				<td>
					<%= Html.Encode(item.Price) %>
				</td>
				<td>
					<%= Html.ActionLink(Html.Resource("Details"), "Details", new { id = item.CommodityID })%>
					 | 
					<%= Html.ActionLink(Html.Resource("Edit"), "Edit", new { id=item.CommodityID })%>
					 | 
					<%= Html.ActionLink(Html.Resource("Delete"), "Delete", new { softwareID=item.SoftwareID })%>
				</td>
			</tr>
			<% } %>

		<% } %>
		</tbody>
	</table>
<% } %>
</asp:Content>
